<?php
include_once("common.inc.php");
require_once(_INC_PATH.'database.php');

$db = new database();
$sql = "show tables";
$db->setQuery($sql);
$data = $db->loadList('','num');

foreach($data as $key=>$value)
{
	$dbname = $value[0];
	$sql = "show columns from $dbname";
	$db->setQuery($sql);
	$columns = $db->loadList('','assoc');
	$update = true;
	foreach($columns as $kk=>$vv)
	{
		if($vv['Field'] == 'update_time'){
			$update = false;
			break;
		}
	}
	if($update){
		$sql = "alter table $dbname add column update_time timestamp";
		$db->query($sql);
	}
	$update = true;
	foreach($columns as $kk=>$vv)
	{
		if($vv['Field'] == 'manager_id'){
			$update = false;
			break;
		}
	}
	if($update){
		$sql = "alter table $dbname add column manager_id int not null default 0";
		$db->query($sql);
	}
}
echo 'finish';